<template>
  <div class="Toppadding subpage">
      <my-head title='地址列表' :back="false" ></my-head>
  <div>
            <van-address-list
            v-model="chosenAddressId"
            :list="palceList"
            @add="onAdd"
            @edit="onEdit"
            @click-item="gotomustOrder"
            />
       </div>
  </div>
</template> 
   
<script>

import { Toast } from 'vant';
export default {
  data() {
    return {
      chosenAddressId: '1',
      palceList:[]
  }},
  methods: {

     async savePlace() {
        let res = await this.$ajax.savePlace({
            phone:this.userInfo.phone//区分用户
        })
        // console.log(res[0].id);
        for(let i=0;i<res.length;i++){
             this.palceList.push({
            id:res[i].id,
            name:res[i].name,
            tel:res[i].tel,
            address:res[i].province + res[i].city +res[i].county 
        })
        }
        console.log(this.palceList);
        
    },
    gotomustOrder(item,index){
          this.$router.push({
              name:'pay',
              query:item
          })
      },

    onAdd() {
     this.$router.push({
          name:'dizhi'
      })
      
    },
    onEdit() {

  
    },
    


    },
      
   mounted(){
      this.savePlace()

  },


  }
</script>